﻿using UnityEngine;

namespace Peril.Physics
{
    public abstract class CollisionShape : ICollisionShape
    {
        public CollisionShape(Vector3 center, Vector3 size, bool twoD = true)
        {
            _Bounds = new Bounds(center,size);
            TwoD = twoD;
        }
        public CollisionShape(Bounds bounds, bool twoD = true)
        {
            _Bounds = bounds;
            TwoD = twoD;
        }

        ///// Fields /////
        private Bounds _Bounds;

        public Bounds Bounds
        {
            get { return _Bounds; }
            set { _Bounds = value; }
        }

        public bool TwoD;

        ///// Properties /////

        public Vector3 Center
        {
            get { return Bounds.center; }
            set { _Bounds.center = value; }
        }

        public Vector3 Extents
        {
            get { return Bounds.extents; }
            set { _Bounds.extents = value; }
        }

        public Vector3 Min { get { return Center - Extents; } }
        public Vector3 Max { get { return Center + Extents; } }

        ///// Methods /////

        public abstract CollisionResult TestCollision(ICollisionShape other);
    }
}
